package com.cloudcc.mobile.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cloudcc.mobile.R;
import com.mypage.bean.RoleAuthority;

import java.util.List;

/**
 * Created by zys on 2017/6/4.
 */

public class NewcontactEditAdapter extends BaseAdapter {
    private Context context;
    private List<RoleAuthority.Roles> mList;

    public NewcontactEditAdapter(Context context, List<RoleAuthority.Roles> mList) {
        this.context = context;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(context, R.layout.pop_list_item, null);
            holder.mRoleName = (TextView) convertView.findViewById(R.id.roleName);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        try {
            holder.mRoleName.setText(mList.get(position).value.toString());
        }catch (Exception ex){
            holder.mRoleName.setText("");
                    }

        return convertView;
    }

    public class ViewHolder {
        TextView mRoleName;
    }
}
